package(default_visibility = ["//visibility:public"])

load("//def:ts.bzl", "jasmine_node_test", "rollup_bundle", "ts_library")

ts_library(
    name = "utils",
    srcs = ["utils.ts"],
)

ts_library(
    name = "utils_test_lib",
    srcs = ["utils_test.ts"],
    deps = [
        ":utils",
        "@npm//@types/jasmine",
    ],
)

jasmine_node_test(
    name = "utils_test",
    srcs = [
        ":utils_test_lib",
    ],
    templated_args = ["--bazel_patch_module_resolver"],
    deps = [
        "@npm//jasmine",
    ],
)

ts_library(
    name = "parser",
    srcs = ["parser.ts"],
    deps = [
        ":utils",
    ],
)

ts_library(
    name = "browser",
    srcs = ["browser.ts"],
    deps = [
        ":parser",
        ":utils",
        "@npm//@types/google.visualization",
    ],
)

rollup_bundle(
    name = "zz.browser_bundle",
    entry_point = ":browser.ts",
    deps = [
        ":browser",
    ],
)

filegroup(
    name = "static",
    srcs = [
        "browser.html",
        ":browser_bundle.es2015.js",
    ],
)

test_suite(
    name = "unit_tests",
    tests = [
        ":utils_test",
    ],
)

filegroup(
    name = "package-srcs",
    srcs = glob(["**"]),
    tags = ["automanaged"],
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [":package-srcs"],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)
